//
//  UIView+extension.swift
//  HaoLie
//
//  Created by arkin on 12/04/2017.
//  Copyright © 2017 higgs. All rights reserved.
//

import UIKit

extension UIView {
    
    public var width: CGFloat {
        return frame.size.width
    }
    
    public var height: CGFloat {
        return frame.size.height
    }
    
    public var px_width: CGFloat {
        return frame.size.width * UIScreen.main.scale
    }
    
    public var px_height: CGFloat {
        return frame.size.height * UIScreen.main.scale
    }
    
    ///添加虚线框
    public func addDotteLineLayer(bound:CGRect,lineColor:UIColor) {
        let layer = CAShapeLayer()
        layer.bounds = bound
        layer.position = CGPoint(x: 0.5 * bound.width, y: 0.5 * bound.height)
        layer.path = CGPath(roundedRect: layer.bounds, cornerWidth: 2, cornerHeight: 2, transform: nil)
        layer.lineWidth = 1
        layer.lineDashPattern = [4,4]
        layer.fillColor = UIColor.clear.cgColor
        layer.strokeColor = UIColor.hex(from: 0xFFDDDDDD).cgColor
        self.layer.addSublayer(layer)
    }
    
}
